<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         let obj = {
            name:"老王",
            age:18
        }
        console.log(obj);
        Object.prototype[Symbol.iterator] = function(){
            // console.log(1);
            // console.log(Object.keys(this));
            let arr = Object.keys(this);
            let index = 0;
            // console.log(this[arr[index]]);
            // console.log(this);
            return {
                next:()=>{
                    // console.log(this);
                    return {
                        value:this[arr[index]],
                        done:index++>=arr.length
                    }
                }
            }
        }
        for(let i of obj){
            console.log(i);
        }
    </script>
</body>
</html>